#lang r5rs
;;
(define (make-acc base)
  (define basis base)
  (lambda(x)
    (begin
      (set! basis (+ basis x))
      basis)))
(define A (make-acc 5))
(display (A 10))
(display (A 10))

(define (make-monitor f)
  (define times 0)
  (lambda(x)
    (if(eq? x 'how-many-calls)
       times
       (begin
         (set! times (+ times 1))
         (f x)))))
(define s (make-monitor sqrt))
(display (s 100))
(display (s 'how-many-calls))
;3.3 3.4 is so boring